package com.shop.cereshop.business.controller.wallet;

import com.shop.cereshop.business.service.wallet.CereShopWalletTransactionService;
import com.shop.cereshop.business.utils.ContextUtil;
import com.shop.cereshop.commons.domain.wallet.CereShopWalletTransaction;
import com.shop.cereshop.commons.exception.CoBusinessException;
import com.shop.cereshop.commons.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 前端控制器
 * 店铺钱包流水表
 * </p>
 *
 * @author
 */
@Slf4j
@RestController
@RequestMapping("/transaction")
@Api(value = "CereShopWalletTransaction", tags = "店铺钱包流水表")
public class CereShopWalletTransactionController {

    @Resource
    private CereShopWalletTransactionService cereShopWalletTransactionService;

    @ApiModelProperty("订单入账列表查询")
    @GetMapping("income/list")
    public Result<List<CereShopWalletTransaction>> getIncomeList(@RequestParam("page") @ApiParam(value = "页码", required = true) Integer page,
                                                                 @RequestParam("pageSize") @ApiParam(value = "页大小", required = true) Integer pageSize) throws CoBusinessException {
        Long shopId = ContextUtil.getShopId();
        if (shopId == null) {
            return Result.unauthorized();
        }
        return Result.success(cereShopWalletTransactionService.getIncomeList(page, pageSize, shopId));
    }
}
